package xm;

import chapter5.service.AdminService;
import chapter5.service.impl.AdminServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/aa")
public class scServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //处理Get请求
        //处理请求的代码
        request.setCharacterEncoding("utf-8");
        //设置相应的格式
        response.setContentType("text/html;charset=utf-8");
        //设置响应的编码格式
        response.setCharacterEncoding("utf-8");



        String id=request.getParameter("name");
        AdminService adminService=new AdminServiceImpl();
        PrintWriter out=response.getWriter();
        int count=adminService.delete(id);
        out.print("{\"count\":"+count+"}");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
